package controller

import (
	"DouBan/bussiness"
	"github.com/gin-gonic/gin"
	"net/http"
)

func JobSubscribe() gin.HandlerFunc {
	return func(context *gin.Context) {
		jobSubscribeRequest := bussiness.JobSubscribeRequest{}
		if err := context.BindJSON(&jobSubscribeRequest); err != nil {
			responseWithError(context, "JobSubscribe", http.StatusBadRequest, "参数错误", err)
			return
		}
		infoClaim := getInfoClaim(context)
		if msg, err := bussiness.JobSubscribe(infoClaim, jobSubscribeRequest); err != nil {
			responseWithError(context, "JobSubscribe", http.StatusBadRequest, msg, err)
		} else {
			responseWithSuccess(context, "JobSubscribe", msg)
		}
	}
}
